<?php
/**
 * 熊猫试玩-检测设备ID是否激活
 * Created by PhpStorm.
 * User: lizhen
 * Date: 2016/9/2
 * Time: 15:11
 */

class PandaPlay implements iController {

    /**
     * 检测设备ID是否激活
     * @param $queryArgs  idfa:设备ID;appId:APPID;
     * @return array|mixed
     */
    public function output($queryArgs) {

        global $uddb;

        if (!empty($queryArgs['idfa']) && !empty($queryArgs['appId']) && !empty($queryArgs['sign'])){

            //验证签名
//            if (md5($queryArgs['idfa'].$queryArgs['appId'].'yaoguo') != $queryArgs['sign'])
//                return json_encode(['status'=> 0]);//签名不匹配

            $sql = 'SELECT `idfa` FROM `youqian_idfa_data` WHERE `idfa`=:idfa AND `app_id`=:appId AND `mission_status`=1';
            $result = $uddb->getVar($sql, array(':idfa' => $queryArgs['idfa'], ':appId' => $queryArgs['appId']));

            if (!empty($result))
                return json_encode([$queryArgs['idfa'] => 1]);//已存在
            else
                return json_encode([$queryArgs['idfa'] => 0]);//不存在
        }
        return  json_encode([$queryArgs['idfa'] => 0]);//缺少参数
    }
}